package com.jiangruan.javaproject.service;/**
 * @author:xulonghua
 * @email:3162193565@qq.com desc:
 * datatime 2021/12/7 16:54
 */

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.Constants;
import com.jiangruan.javaproject.bean.HotVideo;
import com.jiangruan.javaproject.bean.HotVideoCommon;
import com.jiangruan.javaproject.request.HttpUtils;

import java.util.List;

/**
 *@author:xulonghua
 *@email:3162193565@qq.com
 *desc:
 *datetime 2021/12/7 16:54
 */
public class HotVideoService {
    /*
    * 该方法用于获取热门数据并将热门数据返回
    * return*/
    public List<HotVideo> getHotVideo(){
        String url= Constants.TRIP_URL+"?key="+Constants.TRIP_KEY+"&type=hot_video"+"&size=20";
        String result= HttpUtils.get ( url );
        //json解析
        //把result数据解析成HotVideoCommon类型
        HotVideoCommon videoCommon= JSONObject.parseObject ( result, HotVideoCommon.class );
        System.out.println (videoCommon.getResult ().get ( 1 ).getAuthor ());

        return videoCommon.getResult ();
    }
}

